package com.aspose.cells.a.d;

import com.aspose.cells.DateTime;

public class zdk {
   private zeg a;
   private boolean b;
   private zeh c;
   private zde d;
   private zel e;
   private zei f;
   private zdh g;
   private zdc h;
   private zfd i;
   private zdi j;
   private byte[] k;
   private byte[] l;
   private zet m;

   public zdk(com.aspose.cells.b.a.d.zm var1, zei var2) throws Exception {
      this.a(var1, var2, false);
   }

   public void a() throws Exception {
      this.h.a(this.a);
      this.c.a(this.a);
      this.d.a(this.a);
      if (this.n() != null) {
         this.n().a(this.a);
      }

      int var1 = this.a.c();
      this.a(var1);
      this.a.a("%%EOF");
      if (this.b) {
         this.a.e();
      }

   }

   public void a(float var1, float var2) throws Exception {
      if (this.e != null) {
         throw new IllegalStateException("Cannot start a new page while another page is not finished.");
      } else {
         this.e = new zel(this.g, var1, var2);
         this.d.a().a(this.e.n());
      }
   }

   public void a(com.aspose.cells.b.a.b.zt var1) throws Exception {
      this.a(var1.b(), var1.c());
   }

   public void b() throws Exception {
      if (this.e == null) {
         throw new IllegalStateException("No page to end.");
      } else {
         this.e.b();
         this.e.a(this.a);
         this.e = null;
      }
   }

   private void a(com.aspose.cells.b.a.d.zm var1, zei var2, boolean var3) throws Exception {
      this.b = var3;
      this.f = var2;
      this.g = new zdh(this);
      this.a = new zeg(var1);
      this.h = new zdc();
      this.c = new zeh(this.g);
      this.d = new zde(this.g);
      this.a.c("%PDF-1.4");
      if (this.g.b().u()) {
         this.a.a("%");
         this.a.a((byte)-56);
         this.a.a((byte)-55);
         this.a.a((byte)-54);
         this.a.a((byte)-53);
         this.a.a((byte)13);
         this.a.a((byte)10);
      }

      this.c.b(var2.m());
      this.c.a(var2.l());
      this.c.c(var2.k());
      this.c.e(com.aspose.cells.a.c.zs.b());
      if (var2.t()) {
         this.c.a(var2.s());
      } else {
         this.c.a(DateTime.d());
      }

      this.c.d(var2.n());
      if (this.g.b().u()) {
         this.i = new zfd(this.g, this.c);
         this.j = new zdi(this.g);
      }

      if (!var2.t() || var2.q() != null) {
         this.k = com.aspose.cells.b.a.zh.b().a();
         this.l = com.aspose.cells.b.a.zh.b().a();
      }

   }

   private String a(byte[] var1) {
      StringBuilder var2 = new StringBuilder(var1.length);
      byte[] var3 = var1;
      int var4 = var1.length;

      for(int var5 = 0; var5 < var4; ++var5) {
         byte var6 = var3[var5];
         var2.append(com.aspose.cells.b.a.zv.a(com.aspose.cells.b.a.ze.a(var6, 16), 2, (char)'0'));
      }

      return com.aspose.cells.b.a.zr.a(var2).toUpperCase();
   }

   private void a(int var1) throws Exception {
      this.a.c("trailer");
      this.a.g();
      this.a.a("/Size", this.a.a());
      this.a.a("/Info", this.c.n());
      this.a.a("/Root", this.d.n());
      if (this.l() != null && this.m() != null) {
         String var2 = this.a(this.l());
         String var3 = this.a(this.m());
         this.a.c(" /ID [<" + var2 + "><" + var3 + ">]");
      }

      if (this.g.b().q() != null) {
         this.a.a("/Encrypt", this.g.j().n());
      }

      this.a.h();
      this.a.f();
      this.a.c("startxref");
      this.a.c(com.aspose.cells.b.a.zo.a(var1));
   }

   public zei c() {
      return this.f;
   }

   public zel d() {
      return this.e;
   }

   public zes e() {
      return this.h().b();
   }

   public zdc f() {
      return this.h;
   }

   public zej g() {
      return this.d.b();
   }

   public zem h() {
      return this.d.a();
   }

   public zfd i() {
      return this.i;
   }

   public zdi j() {
      return this.j;
   }

   public zdh k() {
      return this.g;
   }

   public byte[] l() {
      return this.k;
   }

   public byte[] m() {
      return this.l;
   }

   public zet n() {
      return this.m;
   }

   public void a(zet var1) {
      this.m = var1;
   }
}
